package 分类.二叉搜索树;
 class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode() {}
      TreeNode(int val) { this.val = val; }
      TreeNode(int val, TreeNode left, TreeNode right) {
          this.val = val;
          this.left = left;
          this.right = right;
      }
  }
public class 二叉搜索树中的搜索 {
    public TreeNode searchBST(TreeNode root, int val) {
          if(root==null) return null;
          if(root.val<val) return searchBST(root.right,val);
          else if(root.val>val) return searchBST(root.left,val);
          return root;
    }

}
